package com.boot.core.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

/**
 * @author Cheng JiYe
 * @description:
 * @date 2020/10/2 18:41
 */
@Configuration
@PropertySource(value = "classpath:application-druid.yml")
@EnableTransactionManagement
@MapperScan(value = {"com.boot.mapper.*"})
public class DruidConfiguration {
    @Bean(destroyMethod = "close", initMethod = "init")
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource druidDataSource() {
        return new DruidDataSource();
    }
}
